package cn.sstech.IM.webserver.user.controller;

import java.util.Date;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.commons.lang.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.google.protobuf.InvalidProtocolBufferException;

import cn.sstech.IM.constant.Constants;
import cn.sstech.IM.server.group.ImChannelGroup;
import cn.sstech.IM.server.model.MessageWrapper;
import cn.sstech.IM.server.model.proto.MessageBodyProto;
import cn.sstech.IM.server.model.proto.MessageProto;
import cn.sstech.IM.server.proxy.impl.MessageProxyImpl;
import cn.sstech.IM.util.result.IBaseResult;
import cn.sstech.IM.webserver.user.model.UserAccountEntity;
import cn.sstech.IM.webserver.user.model.UserFriend;
import cn.sstech.IM.webserver.user.service.SuperManagerService;
import io.swagger.annotations.Api;

@Controller
@RequestMapping("supermanager")
@Api(description="超级管理员相关接口")
public class SuperManagerController {

	@Autowired
	SuperManagerService superManagerService;
	
	@Resource(name= "proxy")
	MessageProxyImpl proxy;
	
	@RequestMapping(value="/broadcast", method=RequestMethod.POST)
	@ResponseBody
	public IBaseResult broadcast(@RequestBody String msgContent
			,HttpServletRequest request){
		HttpSession session = request.getSession();
		UserAccountEntity currentUser = (UserAccountEntity) session.getAttribute(Constants.SessionAttributeName.USER);
		IBaseResult result = superManagerService.broadcast(currentUser,msgContent);

		return result;
	}
}
